//
//  ATLoginViewController.m
//  first
//
//  Created by cuiwenjuan on 14-12-4.
//  Copyright (c) 2014年 cuiwenjuan. All rights reserved.
//

#import "ATLoginViewController.h"

@interface ATLoginViewController ()

@end

@implementation ATLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
     
    
//    [self createloginView];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


 

-(void)createloginView
{
    UIImageView * imageViewBg = [[UIImageView alloc]initWithFrame:self.view.frame];
    [imageViewBg setBackgroundColor:[UIColor grayColor]];
    
    [self.view addSubview:imageViewBg];
    
    UIButton * backBtn = [[UIButton alloc]initWithFrame:CGRectMake(10, 30, 45, 45)];
    
    [backBtn setBackgroundImage:[UIImage imageNamed:@"p_save"] forState:UIControlStateNormal];
    
    [self.view addSubview:backBtn];
    
    [backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    
    //增加点击区域
    UIButton * emptyButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 60, 60)];
    
    [backBtn addSubview:emptyButton];
    
    [emptyButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    
    UILabel * landingLabel = [[UILabel alloc]initWithFrame:CGRectMake(150, 35, 70, 30)];
    [landingLabel setText:@"登陆"];
    [landingLabel setTextAlignment:NSTextAlignmentCenter];
    [landingLabel setFont:[UIFont systemFontOfSize:17]];
    [landingLabel setTextColor:[UIColor whiteColor]];
    [self.view addSubview:landingLabel];
    
    
    
    UIImageView * imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 80, self.view.frame.size.width-10, 141)];
    [imageView setImage:[UIImage imageNamed:@"p_landBg"]];
    [imageView setUserInteractionEnabled:YES];
    
    //用户名
    UIImageView * userImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 15, 40, 40)];
    [userImageView setImage:[UIImage imageNamed:@"p_iconUser"]];
    [imageView addSubview:userImageView];
    
    UITextField * userField = [[UITextField alloc]initWithFrame:CGRectMake(70,15, imageView.frame.size.width - 80, 40)];
    [userField setTextColor:[UIColor whiteColor]];
    [userField setPlaceholder:@"邮箱/用户名"];
    [imageView addSubview: userField];
    
    UIImageView * lineIv = [[UIImageView alloc]initWithFrame:CGRectMake(0, 70, imageView.frame.size.width, 1)];
    [lineIv setImage:[UIImage imageNamed:@"p_lineGrey"]];
    [imageView addSubview: lineIv];
    
    
    //密码
    UIImageView * passwordImageView  = [[UIImageView alloc]initWithFrame:CGRectMake(10, 86, 40, 40)];
    [passwordImageView setImage:[UIImage imageNamed:@"p_iconLock"]];
    [imageView addSubview:passwordImageView];
    
    UITextField * passwordField = [[UITextField alloc]initWithFrame:CGRectMake(70, 86, imageView.frame.size.width - 80, 40)];
    [passwordField setTextColor:[UIColor whiteColor]];
    [passwordField setPlaceholder:@"密码"];
    [imageView addSubview:passwordField];
    
    
    UIButton * forgetPa = [[UIButton alloc]initWithFrame:CGRectMake(imageView.frame.size.width-62, 86, 60, 40)];
    [forgetPa setTitle:@"忘记密码" forState:UIControlStateNormal];
    forgetPa.titleLabel.font = [UIFont systemFontOfSize:12];
    [forgetPa setTintColor:[UIColor whiteColor]];
    [forgetPa addTarget:self action:@selector(findPassword:) forControlEvents:UIControlEventTouchUpInside];
    [imageView addSubview:forgetPa];
    
    
    [self.view addSubview:imageView];
    
    //登陆
    
    UIButton * landButton = [[UIButton alloc]initWithFrame:CGRectMake(5, 261, self.view.frame.size.width-10, 40)];
    
    [landButton setImage:[UIImage imageNamed:@"p_ok"] forState:UIControlStateNormal];
    [landButton setImage:[UIImage imageNamed:@"p_ok_press"] forState:UIControlStateHighlighted];
    [landButton addTarget:self action:@selector(landingButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:landButton];
    
    
    UILabel * landLabel = [[UILabel alloc]initWithFrame:landButton.frame];
    landLabel.bounds = landLabel.bounds;
    [landLabel setText:@"登陆"];
    [landLabel setTextAlignment:NSTextAlignmentCenter];
    [landLabel setTextColor:[UIColor orangeColor]];
    [self.view addSubview:landLabel];
    
    
 
    
    
    //或使用第三方账号登陆。无需注册
    UILabel * threeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 321, self.view.frame.size.width-20, 20)];
    
    [threeLabel setText:@"或使用第三方账号登陆。无需注册"];
    [threeLabel setFont:[UIFont systemFontOfSize:12]];
    [threeLabel setTextColor:[UIColor whiteColor]];
    [self.view addSubview: threeLabel];
    
    //三方账号
    UIImageView * threeImageV = [[UIImageView alloc]initWithFrame:CGRectMake(5, 341, self.view.frame.size.width-10, 80)];
    [threeImageV setImage:[UIImage imageNamed:@"p_landBg"]];
    [threeImageV setUserInteractionEnabled:YES];
    
  
    
    //三个按钮
    UIButton * weixin = [[UIButton alloc]initWithFrame:CGRectMake(threeImageV.frame.size.width/6-25, 15, 50, 50)];
    [weixin setBackgroundImage:[UIImage imageNamed:@"p_weixin_press"] forState:UIControlStateNormal];
    [weixin setTag:101];
    [weixin addTarget:self action:@selector(threeLanding:) forControlEvents:UIControlEventTouchUpInside];
    [threeImageV addSubview: weixin];
    
    
    UIButton * weibo = [[UIButton alloc]initWithFrame:CGRectMake(threeImageV.frame.size.width/6*3-25, 15, 50, 50)];
    [weibo setBackgroundImage:[UIImage imageNamed:@"p_weibo_press"] forState:UIControlStateNormal];
    [weibo setTag:102];
    [weibo addTarget:self action:@selector(threeLanding:) forControlEvents:UIControlEventTouchUpInside];
    [threeImageV addSubview: weibo];
    
    
    UIButton * qq = [[UIButton alloc]initWithFrame:CGRectMake(threeImageV.frame.size.width/6*5-25, 15, 50, 50)];
    [qq setBackgroundImage:[UIImage imageNamed:@"p_qq_press"] forState:UIControlStateNormal];
    [qq setTag:103];
    [qq addTarget:self action:@selector(threeLanding:) forControlEvents:UIControlEventTouchUpInside];
    
    [threeImageV addSubview: qq];

    
    [self.view addSubview:threeImageV];
    
    //没有账号，注册莫比账号
    UILabel * noLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, self.view.frame.size.height-40, self.view.frame.size.width-10, 40)];
    [self.view addSubview:noLabel];
    
    UILabel * nolabel1 = [[UILabel alloc]initWithFrame:CGRectMake(noLabel.frame.size.width/2-155/2, 5, 75, 30)];
//    nolabel1.backgroundColor  = [UIColor orangeColor];
    nolabel1.textColor = [UIColor whiteColor];
    nolabel1.text = @"没有账号？";
    nolabel1.font = [UIFont systemFontOfSize:15];
    [noLabel addSubview: nolabel1];
    
    
    UILabel * nolabel2 = [[UILabel alloc]initWithFrame:CGRectMake(noLabel.frame.size.width/2-155/2+75, 5, 80, 30)];
//    nolabel2.backgroundColor = [UIColor brownColor];
    nolabel2.textColor = [UIColor blueColor];
    nolabel2.text = @"注册莫比账号";
    nolabel2.font = [UIFont systemFontOfSize:13];
    [noLabel addSubview: nolabel2];
    
    UIButton * noButton = [[UIButton alloc]initWithFrame:noLabel.frame];
    [noButton addTarget:self action:@selector(verView:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:noButton];
    
}


-(void)back
{
    [self dismissViewControllerAnimated:YES completion:nil];
}


-(void)findPassword:(UIButton *)button
{
    NSLog(@"进入到找回密码界面");
    
}

-(void)landingButton:(UIButton *)button
{
    NSLog(@"进入到登陆界面");
}


-(void)threeLanding:(UIButton*)button
{

    switch (button.tag) {
        case 101:
            
            NSLog(@"微信登陆");
            break;
        case 102:
            
            NSLog(@"微博登陆");
            break;
        case 103:
            
            NSLog(@"qq登陆");
            break;
       
    }
}


-(void)verView:(UIButton *)button
{
    NSLog(@"进入到注册界面");
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
